Skip to content

perf: skip SDK tracing without span processors - #430

Merged
lesnik512 merged 1 commit into
mainfrom
perf/402-noop-tracing
Nov 4, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
perf/402-noop-tracing

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Metrics-only bootstrap previously installed an SDK tracer provider and recorded spans that had no processor to consume them. Build the SDK provider only when a span processor is configured. Otherwise pass a local no-op provider to framework and custom instrumentors, leaving the global registration slot available.

Preserve an external tracer provider installed before bootstrap and leave its shutdown to the application. Document setup order, late processor attachment, and the effect on JSON trace context.

Closes #402.

Breaking changes

Metrics-only bootstrap no longer installs an SDK tracer provider. Applications that add processors through get_tracer_provider() after bootstrap must instead create and install their own SDK provider before bootstrap. Installing a provider later does not activate instrumentors already given a no-op provider. The same no-op policy applies when a trace exporter is missing and no other processor is configured; the missing-exporter warning remains.

Measurements

Local Python 3.14.7, metrics-only in-process ASGI requests. Median of seven rounds of 5,000 requests after 500 warmup requests. Metrics used a console exporter writing to memory, excluding network I/O; logging, Prometheus, and health routes were disabled.

Framework Before After
FastAPI 148.83 µs/request 108.39 µs/request
Litestar 108.17 µs/request 77.70 µs/request

Validation

  • Metrics-only and external-provider regressions failed before the fix.
  • gRPC and HTTP exporter tests verify recording and export remain intact.
  • FastAPI and Litestar HTTP tests verify metrics collection and external-provider setup before and after bootstrap.
  • just test-ci: 628 passed, 100% coverage.
  • just lint-ci: formatting, lint, and typechecking passed.
  • just docs-build: strict build passed.
  • Standards and spec reviews found no remaining issues.

Preserve an external provider installed before bootstrap. Otherwise pass a local
NoOpTracerProvider to framework and custom instrumentors without consuming the
global registration slot. Keep SDK providers for configured span processors and
leave external provider shutdown to its owner.

Metrics-only and external-provider warning regressions failed first. Both OTLP
exporter protocols still record and export. FastAPI/Litestar HTTP tests verify
metrics collection and provider setup before/after bootstrap.

Local Python 3.14.7 metrics-only ASGI benchmark: 500 warmup requests, seven rounds
of 5000 requests, median elapsed request time. Metrics used ConsoleMetricExporter
with an in-memory output stream to exclude network I/O. Logging, Prometheus and
health routes disabled. Same harness and environment before/after:
- FastAPI: 148.83 -> 108.39 us/request
- Litestar: 108.17 -> 77.70 us/request

Validation: 628 tests passed with 100% coverage; lint, ty and strict docs build
passed. Standards and spec reviews found no remaining issues.
@lesnik512
lesnik512 merged commit 04c278e into main Nov 4, 2026
35 checks passed
@lesnik512
lesnik512 deleted the perf/402-noop-tracing branch November 4, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use a no-op tracer provider when no span processor is configured

1 participant